import React, { Component } from 'react'
import './index.css';
// import Header from '../Header';
// import Main from '../Main';
// import Footer from '../Footer';
// import{nanoid} from 'nanoid'
import axios from 'axios';
// import Hero from '../Hero';
export default class YiYan extends Component {
    state = {
        msg: ''
    }
    render () {
        //一言的接口  http://poetry.apiopen.top/sentences
        return <div className ="container-yiyan">
            <div className="mask"></div>
            <div className="content">
                <div className="top">『</div>
            <div className="text">{this.state.msg}</div>
            <div className="bottom">』</div>
            {/* <button onClick={this.change}  >换一句</button> */}
            </div>
        </div>

    }
         componentDidMount () {
        this.load();
        setInterval(()=>{
            this.load()
        },5000);
    }
    load  = async()=>{
        let result = await axios('http://poetry.apiopen.top/sentences')
        let msg = result.data.result.name;
        console.log(msg)
        this.setState({
            msg: msg
        })
    }
}
